package org.september.pisces.task.controller;

import org.september.pisces.task.entity.SimpleTask;
import org.september.pisces.task.entity.TaskRunningLog;
import org.september.simpleweb.model.ResponseVo;
import org.september.smartdao.CommonDao;
import org.september.smartdao.model.Page;
import org.september.smartdao.model.ParamMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


@Controller
public class TaskLogController {
	
	@Autowired
	private CommonDao commonDao;
	
	@RequestMapping(List_Page)
	public ModelAndView taskList(Long taskId) throws Exception {
		ModelAndView mv = new ModelAndView();
		mv.addObject("taskId", taskId);
		return mv;
	}
	
	@ResponseBody
    @RequestMapping(value = List_Data)
    public ResponseVo<Page<TaskRunningLog>> listTaskData(Page<TaskRunningLog> page,Long taskId) throws Exception {
		ParamMap pm  = new ParamMap();
		pm.put("taskId", taskId);
		page = commonDao.findPageByParams(TaskRunningLog.class, page, "SimpleTask.listLogData", pm);
        return ResponseVo.<Page<TaskRunningLog>> BUILDER().setData(page).setCode(ResponseVo.BUSINESS_CODE.SUCCESS);
    }
	
	private static final String Mapping_Prefix = "/pisces/taskLog";
	public static final String List_Page = Mapping_Prefix+"/logList";
	public static final String List_Data = Mapping_Prefix+"/listTaskLogData";
}
